<!-- BEGIN items -->
<div class="guestbook">
	<div class="gb_item_title"><span style="color:#4499ee">></span><span class='date'>{format_date:date}</span> <span class='name'>{name}</span>：</div>
    <div class="gb_item_content">{content}
    <!-- IF reply_content -->
    	<div class="gb_item_reply"><b>{GB_REPLY}</b>{reply_content}</div>
	<!-- ELSE -->
		<div class="gb_item_reply">{WAITING_REPLY}</div>
    <!-- ENDIF -->
    </div>
</div>
<!-- END -->
<br />
{pager}
<br />


<!-- IF login_user -->
<div class="guestbook new_item">
	<h2>{NEW_GUESTBOOK_ENTRY}</h2>
   	<table cellpadding="0" cellspacing="0" border="0">
    	<tr>
        	<td>{GUESTBOOK_NAME}</td>
            <td><input type="text" guestbook="name" disabled="disabled" class="inputtext" value="{login_user.name}" /></td>
        </tr>
        <tr>
        	<td>{GUESTBOOK_EMAIL}</td>
            <td><input type="text" guestbook="email"  <!-- IF login_user.email -->disabled="disabled"<!-- ENDIF --> class="inputtext" value="{login_user.email}" /></td>
        </tr>
        <tr>
        	<td valign="top">{GUESTBOOK_CONTENT}</td>
            <td><textarea style="width:400px;height:150px;" guestbook="content"></textarea></td>
        </tr>
        <tr>
        	<td></td>
            <td><input type="button" onclick="new_entry()" class="bt" value="{GUESTBOOK_SUBMIT}" />&nbsp;&nbsp;<input type="button" onclick="clear_inputs()" value="{GUESTBOOK_RESET}" class="bt" /></td>
        </tr>
    </table>
</div>
<!-- ELSE -->
	<div style="margin:20px;font-size:15px;">{LOGIN_THEN_WRITE_GUESTBOOK}</div>
<!-- ENDIF -->
<script>
function new_entry()
{
	var name = $('[guestbook=name]').val();
	var email = $('[guestbook=email]').val();
	var content = $('[guestbook=content]').val();
	if (!name || !content)
	{
		alert('{FILL_ALL}');
		return;
	}
	$.post('index.php?p=guestbook&m=new',{ name:name,email:email,content:content},callback);
}

function callback(s)
{
	if (s == 'success')
	{
		alert('{POST_SUCCESS}');
		window.refresh();
	}
	else
	{
		alert(s);
	}
}

function clear_inputs()
{
	$('[guestbook]').val('');
}
</script>